Persistent  ; 阻止脚本自动退出.
OnExit ExitFunc

ExitFunc(ExitReason, ExitCode)
{
    if ExitReason != "Logoff" and ExitReason != "Shutdown"
    {
        Result := MsgBox("Are you sure you want to exit?",, 4)
        if Result = "No"
            return 1  ; 回调必须返回非零值来避免退出.
    }
    ; 不要调用 ExitApp -- 这会阻止其他回调的调用.
}